import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { Button, Text, View } from 'react-native';
// 定义导航的目标页面名称类型
type RootStackParamList = {
  DetailsScreen: undefined; // 表示该页面不需要传递参数
};
// NativeStackNavigationPro类型告诉TS当前使用的是原生栈导航器
type NavigationType = NativeStackNavigationProp<RootStackParamList>;
export default function HomeScreen() {
  const navigation = useNavigation<NavigationType>();
  return (
    <View>
      <Text>我是首页11111111111111111111111</Text>
      <Button
        title="去到详情页"
        onPress={() => navigation.navigate('DetailsScreen')}
      />
      <Button
        title="去到详情页"
        onPress={() => navigation.push('DetailsScreen')}
      />
    </View>
  );
}
